﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace RTS
{
	class Background
	{
		private const int amountTextures = 4;

		private Camera camera;
		private Texture2D texture;

		public Background()
		{ 
			
		}

		public void loadContent(ContentManager Content)
		{
			texture = Content.Load<Texture2D>("the background");
		}

		public void assignCamera(Camera camera)
		{
			this.camera = camera;
		}

		public void draw(SpriteBatch spriteBatch)
		{
			Vector2 centerPos = new Vector2(-camera.CornerPos.X % texture.Width, -camera.CornerPos.Y % texture.Height);

			for (int i = -amountTextures; i < amountTextures; i++)
			{
				for (int j = 1; j < amountTextures; j++)
				{
					spriteBatch.Draw(texture, new Vector2(centerPos.X + texture.Width * i, centerPos.Y + texture.Height * i), Color.White);
					spriteBatch.Draw(texture, new Vector2(centerPos.X + texture.Width * (i + j), centerPos.Y + texture.Height * i), Color.White);
					spriteBatch.Draw(texture, new Vector2(centerPos.X + texture.Width * i, centerPos.Y + texture.Height * (i + j)), Color.White);
				}
			}

		}
	}
}
